package com.walterlife.dp.BuilderDP;

import org.apache.log4j.Logger;

public class Computer {
    // required parameters
    public String HDD;
    public String RAM;

    // optional parameters
    public boolean isGraphicsCardEnabled;
    public boolean isBuletoothEnabled;

    public static Logger logger = Logger.getLogger(Computer.class);

    private Computer(ComputerBuilder computerBuilder) {
        if(computerBuilder != null) {
            this.HDD = computerBuilder.HDD;
            this.RAM = computerBuilder.RAM;
            this.isGraphicsCardEnabled = computerBuilder.isGraphicsCardEnabled;
            this.isBuletoothEnabled = computerBuilder.isBuletoothEnabled;
        } else {
            logger.error("Computer constructer param computerBuilder is null!!!");
        } 
    } 

    public String toString() {
        return ("HDD: " + this.HDD
                + " RAM: " + this.RAM
                + " isGraphicsCardEnabled: " + this.isGraphicsCardEnabled
                + " isBuletoothEnabled: " + this.isBuletoothEnabled);
    } 
    /**
     * @return the hDD
     */
    public String getHDD() {
        return HDD;
    }

    /**
     * @return the rAM
     */
    public String getRAM() {
        return RAM;
    }

    /**
     * @return the isGraphicsCardEnabled
     */
    public boolean isGraphicsCardEnabled() {
        return isGraphicsCardEnabled;
    }

    /**
     * @return the isBuletoothEnabled
     */
    public boolean isBuletoothEnabled() {
        return isBuletoothEnabled;
    }
    
    public static class ComputerBuilder {

        // required parameters
        public String HDD;
        public String RAM;

        // optional parameters
        public boolean isGraphicsCardEnabled;
        public boolean isBuletoothEnabled;
        
        public ComputerBuilder(String HDD, String RAM) {
            this.HDD = HDD;
            this.RAM = RAM;
        }

        /**
         * @param isGraphicsCardEnabled the isGraphicsCardEnabled to set
         */
        public ComputerBuilder setGraphicsCardEnabled(boolean isGraphicsCardEnabled) {
            this.isGraphicsCardEnabled = isGraphicsCardEnabled;
            return this;
        }

        /**
         * @param isBuletoothEnabled the isBuletoothEnabled to set
         */
        public ComputerBuilder setBuletoothEnabled(boolean isBuletoothEnabled) {
            this.isBuletoothEnabled = isBuletoothEnabled;
            return this;
        }
    
        public Computer build() {
            return new Computer(this);
        } 
    } 
} 

